import pygame

class hitbox(object):
    """Used to attach to objects to detect collisions"""
    def __init__(self,parentRect,offsetX, offsetY, width, height ):
        self.parentRect = parentRect #Position is always in relation to center of parentRect
        self.rect = pygame.Rect(0, 0, width, height)
        self.offsetX = offsetX
        self.offsetY = offsetY
        self.rect.center = (parentRect.centerx + self.offsetX, parentRect.centery + self.offsetY)
        
        

    def update(self):
        """Moves the hitbox to be up to date with parent position"""
        self.rect.center = (self.parentRect.centerx + self.offsetX, self.parentRect.centery + self.offsetY)

    def draw(self, camera, screen):
        """Used for seeing where the hitboxes currently are"""
        pygame.draw.rect(screen, (0,255,0), (self.rect.topleft[0] - camera.rect.topleft[0],self.rect.topleft[1] - camera.rect.topleft[1], self.rect.width, self.rect.height))
